package com.united.ucts.common.plugin.swagger;

import com.united.frame.swagger2.Contact;
import com.united.frame.swagger2.SwaggerProperties;
import com.united.frame.swagger2.annotation.EnableSwagger;
import com.united.frame.swagger2.config.AbstractSwaggerConfiguration;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;

/**
 * Swagger API文档相关配置
 *
 * @author hudan
 * @version 1.0
 * @filename SwaggerConfiguration.java
 * @copyright <a href="www.united.cn">www.united.cn</a>
 * @date 2019-10-26
 */
@EnableSwagger
public class SwaggerConfiguration extends AbstractSwaggerConfiguration {

    /**
     * 自定义的具体某个微服务的Swagger配置
     *
     * @return 自定义的swagger配置参数信息
     */
    @Override
    public SwaggerProperties swaggerProperties() {
        return SwaggerProperties.builder()
                .title("ucts后台系统")
                .description("ucts后台相关接口文档")
                .contact(Contact.builder()
                        .name("hudan729046")
                        .url("https://gitee.com/hudan729046/united-busi.git")
                        .email("hudan729046@163.com")
                        .build())
                .version("1.0")
                .enableSecurity(true)
                .build();
    }

    /**
     * 自定义的BeanPostProcessor用于解决升级支持SpringCloud-2021后;无法展示Knife4j文档问题
     *
     * @return 自定义后的BeanPostProcessor
     */
    @Bean
    public BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
        return generateBeanPostProcessor();
    }
}